home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 January - Disc 2
/
Macworld (1999-01) (Disk 2).dmg
/
Serious Demos
/
Symbolic Composer 4.2
/
Environment
/
Projects
/
Contributed Scores
/
Peter Stone Punctus
/
Symmetries
< prev
next >
Wrap
Lisp/Scheme
|
1998-10-26
|
8KB
|
180 lines
(def-orchestra 'orchestra
piano (lefthand1 righthand1 lefthand2 righthand2)
)
;;; part b
(defun filter-harmonize2 (mel1 mel2 mod-val tonality n-control s-values)
(diagnostic2 "filter-harmonize" $cr$)
(setq mel1 (symbol-trim (length mel2) mel1))
(prog (out1 out2 gap swap counter n n-times n-count n-values s-master semitones
maptable)
(setq maptable (build-maptable (car tonality)))
(setq counter 0)
(setq swap t)
(setq s-master s-values)
(setq semitones (car s-master))
(setq n-values n-control)
(setq n (caar n-values))
(setq n-times (cadar n-values))
(setq n-count 0)
loop
(cond ((null mel2) (return (list (nreverse out2) (nreverse out1)))))
(cond ((= counter n)
(setq counter 0)
(setq n-count (1+ n-count))
(setq swap (not swap))))
(setq counter (1+ counter))
(cond ((= n-count n-times)
(setq s-master (cdr s-master))
(when (null s-master)
(setq s-master s-values))
(setq semitones (car s-master))
(setq n-count 0)
(setq n-values (cdr n-values))
(when (null n-values)
(setq n-values n-control))
(setq n (caar n-values))
(setq n-times (cadar n-values))))
(if swap
(cond ((or (equal (car mel1) '=) (equal (car mel2) '=))
(push (car mel1) out2)
(push (car mel2) out1))
(t (setq gap (abs (- (symbol-to-mapped-integer (car mel1) maptable)
(symbol-to-mapped-integer (car mel2) maptable))))
(cond ((member (mod gap mod-val) semitones)
(push (closest-harmony (symbol-to-mapped-integer (car mel2) maptable)
(symbol-to-mapped-integer (car mel1) maptable)
(car mel1) (car mel2))
out1)
(push (car mel1) out2))
(t (push (car mel2) out1)
(push (car mel1) out2)))))
(cond ((or (equal (car mel1) '=) (equal (car mel2) '=))
(push (car mel2) out1)
(push (car mel1) out2))
(t (setq gap (abs (- (symbol-to-mapped-integer (car mel1) maptable)
(symbol-to-mapped-integer (car mel2) maptable))))
(cond ((member (mod gap mod-val) semitones)
(push (closest-harmony (symbol-to-mapped-integer (car mel1) maptable)
(symbol-to-mapped-integer (car mel2) maptable)
(car mel2) (car mel1))
out2)
(push (car mel2) out1))
(t (push (car mel1) out2)
(push (car mel2) out1))))))
(pop mel1)
(pop mel2)
(go loop)))
(defun closest-harmony (m1 m2 s1 s2)
(if (> (get-random 0 10) 5)
'=
(integer-to-symbol (+ (symbol-to-integer s2) 3))))
(defun symbol-mod (n offset s)
(if (equal s '=)
'=
(if (< (symbol-to-integer s) n)
s
(integer-to-symbol (+ offset (mod (symbol-to-integer s) n))))))
(defun symbol-fold (n offset s)
(mapcar #'(lambda (x) (symbol-mod n offset x)) s))
(init-rnd 0.79823621123)
(setq freq (fibonacci (setq fib (get-random 3 20))))
(setq samples (* 512 (/ 256 32)))
(setq modulator (vector-mix (gen-ramp (fibonacci (setq r1 (get-random 3 20))) 0.4 samples)
(gen-triangle (fibonacci (setq r2 (get-random 3 20))) 0.35 samples)))
(setq theme (vector-to-symbol a z
(vector-modulate (gen-sin freq 0.5 samples)
modulator)))
(setq melody-1-source theme)
(setq melody-2-source
(vector-to-symbol a z
(vector-modulate (gen-sin freq 0.5 samples 90)
modulator)))
(setq harmonized-melodies
(filter-harmonize2 melody-1-source melody-2-source 24
(activate-tonality (major g 3))
'((16 2) (2 16))
'((1 2 6 10 11))))
(setq melody-1-mat (symbol-fold 14 7 (filter-deactivate 4 40 (find-change (car harmonized-melodies)))))
(setq melody-2-mat (symbol-fold 14 7 (filter-deactivate 3 50 (find-change (cadr harmonized-melodies)))))
(setq melody-1 melody-1-mat)
(setq melody-2
(symbol-remove
(find-common melody-1-mat melody-2-mat)
melody-2-mat))
(setq tempo-zone-len (/ (get-ratio '256/1 :ratio)
(get-ratio '1/8 :ratio)))
(def-section prelude4
default
zone '(256/1)
tempo-zones (symbol-trim tempo-zone-len '(1/8))
tempo (vector-to-list (vector-round 58 85 (gen-fourier
'(0.9 2 5 7) ; frequencies
'(0.9 0.4 (gen-sin 40 0.22 64) 0.2) ; amplitudes
'(0 45 90) ; initial phases
tempo-zone-len)))
lefthand1
channel 4
tonality (activate-tonality (hirajoshi g 3 4024))
symbol melody-1
length (vector-to-list (length-quantize 1/16 -1/8 1/2 (vector-modulate (gen-sin freq 0.5 samples)
modulator)))
duration (vector-to-list (vector-round (get-tick '3/1) (get-tick '1/20) (vector-modulate (gen-sin freq 0.5 samples 90)
modulator)))
velocity (symbol-to-velocity 35 110 3 (symbol-scroll 256 theme))
tuning (vector-to-list (vector-round -300 300 (gen-noise-white samples 1 0.1212)))
righthand1
channel 1
tonality (activate-tonality (hirajoshi g 2 4024))
symbol melody-2
length (vector-to-list (length-quantize 1/16 -1/8 1/2 (vector-modulate (gen-sin freq 0.5 samples 90)
modulator)))
duration (vector-to-list (vector-round (get-tick '3/1) (get-tick '1/20) (vector-modulate (gen-sin freq 0.5 samples)
modulator)))
velocity (symbol-to-velocity 35 70 2 (reverse theme))
tuning (vector-to-list (vector-round -300 300 (gen-noise-white samples 1 0.212)))
lefthand2
channel 2
tonality (activate-tonality (hirajoshi g 3 4024))
symbol melody-1
length (vector-to-list (length-quantize 1/16 -1/8 1/2 (vector-modulate (gen-sin freq 0.5 samples)
modulator)))
duration (vector-to-list (vector-round (get-tick '3/1) (get-tick '1/20) (vector-modulate (gen-sin freq 0.5 samples 90)
modulator)))
velocity (symbol-to-velocity 35 110 3 (symbol-scroll 256 theme))
;tuning (vector-to-list (vector-round -300 300 (gen-noise-white samples 1 0.51212)))
righthand2
channel 5
tonality (activate-tonality (hirajoshi g 2 4024))
symbol melody-2
length (vector-to-list (length-quantize 1/16 -1/8 1/2 (vector-modulate (gen-sin freq 0.5 samples 90)
modulator)))
duration (vector-to-list (vector-round (get-tick '3/1) (get-tick '1/20) (vector-modulate (gen-sin freq 0.5 samples)
modulator)))
velocity (symbol-to-velocity 35 70 2 (reverse theme))
;tuning (vector-to-list (vector-round -300 300 (gen-noise-white samples 1 0.52212)))
)
(midiport :printer)
(play-file-p nil ; nil places song midi in the same directory as the score
piano '(prelude4)
)